package com.art.museumbackend.mapper;

import com.art.museumbackend.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<Role> {
    @Select("SELECT permission_id FROM role_permission WHERE role_id = #{roleId}")
    List<Integer> getPermissionsByRoleId(Integer roleId);

    @Delete("DELETE FROM role_permission WHERE role_id = #{roleId}")
    void deleteRolePermissions(Integer roleId);

    @Insert("INSERT INTO role_permission(role_id, permission_id) VALUES(#{roleId}, #{permissionId})")
    void insertRolePermission(Integer roleId, Integer permissionId);
} 